/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mimp.hibernate;

import java.util.ArrayList;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author john
 */
public class Helper {

    Session session = null;

    public Helper() {
        this.session = HibernateUtil.getSessionFactory().getCurrentSession();
    }

    public ArrayList login(String user, String pass) {
        ArrayList<Object> lista = new ArrayList<Object>();
        
        try {
            org.hibernate.Transaction tx = session.beginTransaction();
            Query q = session.createQuery("from Personal as personal where personal.user = '" + user + "' and personal.pass = '" + pass + "'");
            lista.add(q.list().get(0));
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        return lista;
    }
}
